package com.nanuminc.market.today;

import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.net.Uri;
import android.content.Intent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.ViewFlipper;
import android.widget.Button;

import com.nanuminc.market.R;

public class TodayFullView_ngoc extends Activity{
	ViewFlipper mFlip = null;
	Button mdial_bt = null;
	float oldTouchValue;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.todayfullview_ngoc);
		mFlip = (ViewFlipper)findViewById(R.id.flip);
		mdial_bt = (Button)findViewById(R.id.callbutton1);
		mdial_bt.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				performDial();
			}
		});	
	}
	
	public void performDial() {		       
	    //Catch Exception I/O 작성 
		startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:010-0000-0000")));// + mEdtNumber.getText())));		      
    }


	
	
	@Override
	//This method is for dragging mouse to view images on todayfullview_ngoc layout
	public boolean onTouchEvent(MotionEvent touchEvent) {
		Log.e("hyup2","touchEvent = "+touchEvent);
		switch (touchEvent.getAction()) {
		case MotionEvent.ACTION_DOWN: {
			oldTouchValue = touchEvent.getX();
			break;
		}
		case MotionEvent.ACTION_UP: {
			float currentX = touchEvent.getX();
			if (oldTouchValue < currentX) {
				mFlip.setInAnimation(AnimationHelper.inFromLeftAnimation());
				mFlip.setOutAnimation(AnimationHelper.outToRightAnimation());
				mFlip.showNext();
			}
			if (oldTouchValue > currentX) {
				mFlip.setInAnimation(AnimationHelper.inFromRightAnimation());
				mFlip.setOutAnimation(AnimationHelper.outToLeftAnimation());
				mFlip.showPrevious();
			}
			break;
		}
		case MotionEvent.ACTION_MOVE: {
			// TODO: Some code to make the ViewFlipper
			// act like the home screen.
			break;
		}
		}
		return false;
	}
	
	public static class AnimationHelper { 
		  public static Animation inFromRightAnimation() { 
		    Animation inFromRight = new TranslateAnimation( 
		    Animation.RELATIVE_TO_PARENT, +1.0f, 
		    Animation.RELATIVE_TO_PARENT, 0.0f, 
		    Animation.RELATIVE_TO_PARENT, 0.0f, 
		    Animation.RELATIVE_TO_PARENT, 0.0f); 
		    inFromRight.setDuration(500); 
		    inFromRight.setInterpolator(new AccelerateInterpolator()); 
		    return inFromRight; 
		  } 
		 
		  public static Animation outToLeftAnimation() { 
		    Animation outtoLeft = new TranslateAnimation( 
		    Animation.RELATIVE_TO_PARENT, 0.0f, 
		    Animation.RELATIVE_TO_PARENT, -1.0f, 
		    Animation.RELATIVE_TO_PARENT, 0.0f, 
		    Animation.RELATIVE_TO_PARENT, 0.0f); 
		    outtoLeft.setDuration(500); 
		    outtoLeft.setInterpolator(new AccelerateInterpolator()); 
		    return outtoLeft; 
		  } 
		 
		  // for the next movement 
		  public static Animation inFromLeftAnimation() { 
		    Animation inFromLeft = new TranslateAnimation( 
		    Animation.RELATIVE_TO_PARENT, -1.0f, 
		    Animation.RELATIVE_TO_PARENT, 0.0f, 
		    Animation.RELATIVE_TO_PARENT, 0.0f, 
		    Animation.RELATIVE_TO_PARENT, 0.0f); 
		    inFromLeft.setDuration(500); 
		    inFromLeft.setInterpolator(new AccelerateInterpolator()); 
		    return inFromLeft; 
		  } 
		 
		  public static Animation outToRightAnimation() { 
		    Animation outtoRight = new TranslateAnimation( 
		    Animation.RELATIVE_TO_PARENT, 0.0f, 
		    Animation.RELATIVE_TO_PARENT, +1.0f, 
		    Animation.RELATIVE_TO_PARENT, 0.0f, 
		    Animation.RELATIVE_TO_PARENT, 0.0f); 
		    outtoRight.setDuration(500); 
		    outtoRight.setInterpolator(new AccelerateInterpolator()); 
		    return outtoRight; 
		  } 
		}

	@Override  
	protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first)  
	{  
	    super.onApplyThemeResource(theme, resid, first);  
	          
	    // no background panel is shown  
	    theme.applyStyle(android.R.style.Theme_Panel, true);  
	}
	

}

